using HCore.IOC.Beans.Factory.Attribute.Attr;
using HCore.IOC.Context.Event.Attr;
using HCore.Tests.Runtime.DianDianDian.Event;
using HCore.Tests.Runtime.DianDianDian.Model;
using UnityEngine;

namespace HCore.Tests.Runtime.DianDianDian.System
{
    [IOC.Context.Stereotype.Component]
    public class ScoreSystem
    {
        [Autowired] private ICountDownSystem mCountDownSystem;
        [Autowired] private IGameModel mGameModel;

        [EventListener]
        public void OnGamePassEvent(GamePassEvent @event)
        {
            var remainSeconds = mCountDownSystem.GetCurrentRemainSeconds();
            Debug.Log($"当前剩余{remainSeconds}秒，同步增加{remainSeconds * 10}积分。");

            mGameModel.Score += remainSeconds;

            Debug.Log($"当轮得分：{mGameModel.Score}， 最佳得分：{mGameModel.BestScore}");
            if (mGameModel.Score > mGameModel.BestScore)
            {
                mGameModel.BestScore = mGameModel.Score;
                Debug.Log("新纪录！");
            }
        }

        [EventListener]
        private void OnEnemyKillEvent(EnemyKillEvent @event)
        {
            mGameModel.Score += 10;
            Debug.Log($"得分：10， 当前分数：{mGameModel.Score}");
        }


        [EventListener]
        private void OnMissEvent(MissEvent @event)
        {
            mGameModel.Score -= 5;
            Debug.Log($"扣分：5， 当前分数：{mGameModel.Score}");
        }
    }
}